class LiberacaoController {

    static allowedMethods = [save: "POST", update: "POST", delete: "POST"]
    def authenticateService


    def list = {
       
        [liberacaoInstanceList: Liberacao.list(params), liberacaoInstanceTotal: Liberacao.count()]
    }

    def create = {

        def   liberacaoInstance  = Liberacao.list('sort':'id' , 'order':'desc')[0]
        if (!liberacaoInstance) {
        liberacaoInstance = new Liberacao()
        liberacaoInstance.properties = params
        }

        return ['liberacaoInstance': liberacaoInstance , 'usuario' : Usuario.findByUsername(authenticateService.principal().getUsername())]
    }

    def save = {
        println params
        def liberacaoInstance = new Liberacao(params)
        if (liberacaoInstance.save(flush: true)) {
            flash.message = "${message(code: 'default.created.message', args: [message(code: 'liberacao.label', default: 'Liberacao'), liberacaoInstance.id])}"
            redirect(controller : 'inscricao' ,action: "list")
        }
        else {

             liberacaoInstance.errors.allErrors.each {
        println it
    }

            render(view: "create", model: [liberacaoInstance: liberacaoInstance])
        }
    }



}
